Unexpected Exception in Php DateTime #4697
Merged
+199
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #4696. Fix #917 (which had gone stale but is now reopened). Fix #916. People were receiving unexpected exceptions calling
Date::isDateTime($cell). 916 and 917 had been mostly resolved long ago by adding a numeric check on the contents of $cell. However, it turns out that the use of values with very large absolute values can cause Php DateTime to throw an exception, which is the problem with 4696, when it callsDate::exceTolDateTimeObjectfor a cell with a large integer value.Date::excelToDateTimeObjectis coded to return a Php DateTime object. I don't see any reasonable non-breaking fix for that. People can always add try/catch if they are worried about that. However,Date::isDateTimecan add an additional check and returnfalseif this situation occurs. All 3 of the issues resolved by this PR mention isDateTime in their discussion; they are all fixed without additional coding changes by this.An additional change is needed for
Cell::getFormattedValueto avoid this problem. This is fixed inStyle::NumberFormatter::DateFormatter::format.This is:
Checklist: